package com.service.device;

import com.dao.secondary.device.DevicePcbSensorInfoMapper;
import com.github.pagehelper.PageHelper;
import com.model.domain.device.GetDevicePcbSensorInfoDO;
import com.model.pojo.device.DevicePcbBaseInfo;
import com.model.pojo.device.DevicePcbSensorInfo;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;


/**
 * @Author: zql
 * @Description: PCB设备传感器信息服务
 * @Data: 2023-03-29
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class DevicePcbSensorInfoService {
    private final DevicePcbSensorInfoMapper devicePcbSensorInfoMapper;

    /**
     * 查询全部记录
     * @author tm
     * @date 2023-04-15 14:35
     * @param getDevicePcbSensorInfoDO
     * @return List<DevicePcbSensorInfo>
     */
    public List<DevicePcbSensorInfo> getAllList(GetDevicePcbSensorInfoDO getDevicePcbSensorInfoDO){
        PageHelper.clearPage();
        PageHelper.orderBy(getDevicePcbSensorInfoDO.getSortRow() + getDevicePcbSensorInfoDO.getSortOrder());
        return devicePcbSensorInfoMapper.selectList(getDevicePcbSensorInfoDO);
    }

    public DevicePcbSensorInfo getById(Long sensorId){
        return devicePcbSensorInfoMapper.selectByPrimaryKey(sensorId);
    }

    public int update(DevicePcbSensorInfo info){
        info.setLastModifiedTime(new Date());
        return devicePcbSensorInfoMapper.updateByPrimaryKeySelective(info);
    }
}
